package com.future.lock.find.adapter;

import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.future.lock.R;
import com.future.lock.find.bean.FindListBean;
import com.future.lock.find.utils.GlideRoundTransformation;

import java.util.List;

/**
 * Created by jniu on 2017/11/20.
 */

public class FindAdapter extends BaseMultiItemQuickAdapter<FindListBean,BaseViewHolder> {

    /**
     * Same as QuickAdapter#QuickAdapter(Context,int) but with
     * some initialization data.
     *
     * @param data A new list is created out of this one to avoid mutable list
     */
    public FindAdapter(List<FindListBean> data) {
        super(data);
        addItemType(FindListBean.TYPE_IMG, R.layout.item_find_img);
        addItemType(FindListBean.TYPE_VIDEO, R.layout.item_find_video);
    }

    @Override
    protected void convert(BaseViewHolder helper, FindListBean item) {
        helper.setText(R.id.tv_title,item.title);
        helper.setText(R.id.tv_time,item.time);
        helper.setText(R.id.tv_comment_count,item.commentCount+"评论");
        Glide.with(mContext)
                .load(item.imgUrl)
                .placeholder(R.color.default_img)
                .transform(new GlideRoundTransformation(mContext,2))
                .into((ImageView) helper.getView(R.id.imageView));
    }
}
